<?php
use think\Config;
/**
 *  @file : redis.php
 *  @brief: redis适配
 */
return call_user_func(function() {
  $retn = [];
  $host = IS_CLI ? '' : \think\Request::instance()->host(true);
  $name = basename(__FILE__, '.php');
  $cons = [
    '88' => [
      'hostname'    => '47.110.144.135',
      'password'    => '789789',
      'hostport'    => 6379,
      'database'    => 0,
      'timeout'     => 10,
      'persistent'  => false,
    ],
  ];
  
  foreach($cons as $key => $val) {
    Config::set($name, $val, $key);  // 写进作用域
  }

  $alias = array_keys($cons);
  list($hh) = explode('.', $host);
  if (in_array($hh, $alias)) {
    $range = $hh;
  } else {
    $range = $alias[0];
  }
  $retn = Config::get($name, $range);
  return $retn;
});
